home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / qwindows.arc / GETSCRN.8 next >
Encoding:
Text File  |  1987-04-03  |  1.8 KB  |  53 lines

  1. ;This is a procedure callable from QBasic to get the old screen from a
  2. ;buffer passed as the address of a 2000 integer array.
  3.  
  4. Name      Getscrn             ;Name used at link time
  5. Public    Getscrn             ;Only label that is public
  6.  
  7. Getscrn:  org       0         ;Since we will link later
  8.           jmp  short Getpara                 ;Get parameters
  9.  
  10. Vidmem    equ       0B800h                   ;Video page 1 segment
  11. Scrnbuf:  dw        ?                        ;Screen buffer location from Basic
  12. Msg1:     db   'Not in a color mode now.$'   ;Error message
  13.           
  14. Getpara:  push      bp
  15.           mov       bp,sp
  16.           push      es
  17.           push      ds
  18.           push      cs        ;es=cs
  19.           pop       es
  20.           cld
  21.           mov       bx,[bp+6]  ;Get address of screen buffer location in ds
  22.           mov       ax,[bx]    ;Get location of screen buffer in ds
  23.           mov       cs:[Scrnbuf],ax
  24.  
  25. ;Get current video mode and page
  26.           mov  ah,15     ;Get current video mode
  27.           int  10h
  28.           cmp  al,2      ;Mode 2?
  29.           je   Color     ;Yes
  30.           cmp  al,3      ;Mode 3?
  31.           je   Color     ;Yes
  32.           mov  dx,Msg1   ;No, print message
  33.           mov  ah,9
  34.           int  21h
  35. Exit:                    ;Return to Basic
  36.           pop  ds
  37.           pop  es
  38.           pop  bp
  39.           retf 2         
  40.  
  41. Color:                   ;Find video memory.
  42.           cld            ;Set to inc si & di
  43.           mov  bl,0      ;bx=page offset
  44.           add  bx,Vidmem ;Add page 0 address
  45.  
  46. ;Save current screen.
  47.           mov  es,bx     ;Set dest segment for screen mem
  48.           mov  si,cs:[Scrnbuf] ;Point source to buffer in in ds
  49.           mov  di,0      ;Start of screen
  50.           mov  cx,80*25  ;Words to move
  51.           rep  movsw     ;Move them
  52.           jmp  Exit
  53.